package com.sline.ThreadMethod;

public class Demo5_Join {
    public static void main(String[] args) {
        Thread t1 = new Thread() {
            public void run() {
                for (int i = 0; i < 5000; i++) {
                    System.out.println(this.getName() + " aaaaaaaaaaaaa");
                }
            }
        };

        Thread t2 = new Thread() {
            public void run() {
                for (int i = 0; i < 5000; i++) {

                    if (i == 10) {
                        try {
                            t1.join(1);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                    System.out.println(this.getName() + " bb");
                }
            }
        };

        t2.start();
        t1.start();
    }
}
